Optimal. Leaf size=90 \[ -2 a b x+\frac {\left (2 a^2-b^2\right ) \tanh ^{-1}(\sin (c+d x))}{2 d}-\frac {3 a^2 \sin (c+d x)}{2 d}+\frac {a b \tan (c+d x)}{d}+\frac {(b+a \cos (c+d x))^2 \sec (c+d x) \tan (c+d x)}{2 d} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.30, antiderivative size = 90, normalized size of antiderivative = 1.00, number of steps
used = 7, number of rules used = 7, integrand size = 26, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.269, Rules used = {4482, 2968,
3127, 3110, 3102, 2814, 3855} \begin {gather*} \frac {\left (2 a^2-b^2\right ) \tanh ^{-1}(\sin (c+d x))}{2 d}-\frac {3 a^2 \sin (c+d x)}{2 d}+\frac {a b \tan (c+d x)}{d}+\frac {\tan (c+d x) \sec (c+d x) (a \cos (c+d x)+b)^2}{2 d}-2 a b x \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 2814
Rule 2968
Rule 3102
Rule 3110
Rule 3127
Rule 3855
Rule 4482
Rubi steps
\begin {align*} \int \sec (c+d x) (a \sin (c+d x)+b \tan (c+d x))^2 \, dx &=\int (b+a \cos (c+d x))^2 \sec (c+d x) \tan ^2(c+d x) \, dx\\ &=\int (b+a \cos (c+d x))^2 \left (1-\cos ^2(c+d x)\right ) \sec ^3(c+d x) \, dx\\ &=\frac {(b+a \cos (c+d x))^2 \sec (c+d x) \tan (c+d x)}{2 d}+\frac {1}{2} \int (b+a \cos (c+d x)) \left (2 a-b \cos (c+d x)-3 a \cos ^2(c+d x)\right ) \sec ^2(c+d x) \, dx\\ &=\frac {a b \tan (c+d x)}{d}+\frac {(b+a \cos (c+d x))^2 \sec (c+d x) \tan (c+d x)}{2 d}-\frac {1}{2} \int \left (-2 a^2+b^2+4 a b \cos (c+d x)+3 a^2 \cos ^2(c+d x)\right ) \sec (c+d x) \, dx\\ &=-\frac {3 a^2 \sin (c+d x)}{2 d}+\frac {a b \tan (c+d x)}{d}+\frac {(b+a \cos (c+d x))^2 \sec (c+d x) \tan (c+d x)}{2 d}-\frac {1}{2} \int \left (-2 a^2+b^2+4 a b \cos (c+d x)\right ) \sec (c+d x) \, dx\\ &=-2 a b x-\frac {3 a^2 \sin (c+d x)}{2 d}+\frac {a b \tan (c+d x)}{d}+\frac {(b+a \cos (c+d x))^2 \sec (c+d x) \tan (c+d x)}{2 d}-\frac {1}{2} \left (-2 a^2+b^2\right ) \int \sec (c+d x) \, dx\\ &=-2 a b x+\frac {\left (2 a^2-b^2\right ) \tanh ^{-1}(\sin (c+d x))}{2 d}-\frac {3 a^2 \sin (c+d x)}{2 d}+\frac {a b \tan (c+d x)}{d}+\frac {(b+a \cos (c+d x))^2 \sec (c+d x) \tan (c+d x)}{2 d}\\ \end {align*}
________________________________________________________________________________________
Mathematica [A]
time = 0.22, size = 75, normalized size = 0.83 \begin {gather*} \frac {-4 a b \text {ArcTan}(\tan (c+d x))+\left (2 a^2-b^2\right ) \tanh ^{-1}(\sin (c+d x))-2 a^2 \sin (c+d x)+4 a b \tan (c+d x)+b^2 \sec (c+d x) \tan (c+d x)}{2 d} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.13, size = 98, normalized size = 1.09
method | result | size |
derivativedivides | \(\frac {a^{2} \left (-\sin \left (d x +c \right )+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )+2 a b \left (\tan \left (d x +c \right )-d x -c \right )+b^{2} \left (\frac {\sin ^{3}\left (d x +c \right )}{2 \cos \left (d x +c \right )^{2}}+\frac {\sin \left (d x +c \right )}{2}-\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )}{d}\) | \(98\) |
default | \(\frac {a^{2} \left (-\sin \left (d x +c \right )+\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )\right )+2 a b \left (\tan \left (d x +c \right )-d x -c \right )+b^{2} \left (\frac {\sin ^{3}\left (d x +c \right )}{2 \cos \left (d x +c \right )^{2}}+\frac {\sin \left (d x +c \right )}{2}-\frac {\ln \left (\sec \left (d x +c \right )+\tan \left (d x +c \right )\right )}{2}\right )}{d}\) | \(98\) |
risch | \(-2 a b x +\frac {i {\mathrm e}^{i \left (d x +c \right )} a^{2}}{2 d}-\frac {i {\mathrm e}^{-i \left (d x +c \right )} a^{2}}{2 d}-\frac {i b \left (b \,{\mathrm e}^{3 i \left (d x +c \right )}-4 a \,{\mathrm e}^{2 i \left (d x +c \right )}-b \,{\mathrm e}^{i \left (d x +c \right )}-4 a \right )}{d \left ({\mathrm e}^{2 i \left (d x +c \right )}+1\right )^{2}}+\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right ) a^{2}}{d}-\frac {b^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}+i\right )}{2 d}-\frac {\ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right ) a^{2}}{d}+\frac {b^{2} \ln \left ({\mathrm e}^{i \left (d x +c \right )}-i\right )}{2 d}\) | \(185\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.47, size = 102, normalized size = 1.13 \begin {gather*} -\frac {8 \, {\left (d x + c - \tan \left (d x + c\right )\right )} a b + b^{2} {\left (\frac {2 \, \sin \left (d x + c\right )}{\sin \left (d x + c\right )^{2} - 1} + \log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right )\right )} - 2 \, a^{2} {\left (\log \left (\sin \left (d x + c\right ) + 1\right ) - \log \left (\sin \left (d x + c\right ) - 1\right ) - 2 \, \sin \left (d x + c\right )\right )}}{4 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [A]
time = 2.24, size = 126, normalized size = 1.40 \begin {gather*} -\frac {8 \, a b d x \cos \left (d x + c\right )^{2} - {\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} \log \left (\sin \left (d x + c\right ) + 1\right ) + {\left (2 \, a^{2} - b^{2}\right )} \cos \left (d x + c\right )^{2} \log \left (-\sin \left (d x + c\right ) + 1\right ) + 2 \, {\left (2 \, a^{2} \cos \left (d x + c\right )^{2} - 4 \, a b \cos \left (d x + c\right ) - b^{2}\right )} \sin \left (d x + c\right )}{4 \, d \cos \left (d x + c\right )^{2}} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [F]
time = 0.00, size = 0, normalized size = 0.00 \begin {gather*} \int \left (a \sin {\left (c + d x \right )} + b \tan {\left (c + d x \right )}\right )^{2} \sec {\left (c + d x \right )}\, dx \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 171 vs.
\(2 (84) = 168\).
time = 0.99, size = 171, normalized size = 1.90 \begin {gather*} -\frac {4 \, {\left (d x + c\right )} a b - {\left (2 \, a^{2} - b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) + 1 \right |}\right ) + {\left (2 \, a^{2} - b^{2}\right )} \log \left ({\left | \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - 1 \right |}\right ) + \frac {4 \, a^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )}{\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} + 1} + \frac {2 \, {\left (4 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{3} - 4 \, a b \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right ) - b^{2} \tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )\right )}}{{\left (\tan \left (\frac {1}{2} \, d x + \frac {1}{2} \, c\right )^{2} - 1\right )}^{2}}}{2 \, d} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 0.79, size = 147, normalized size = 1.63 \begin {gather*} \frac {2\,a^2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d}-\frac {a^2\,\sin \left (c+d\,x\right )}{d}-\frac {b^2\,\mathrm {atanh}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d}+\frac {b^2\,\sin \left (c+d\,x\right )}{2\,d\,{\cos \left (c+d\,x\right )}^2}-\frac {4\,a\,b\,\mathrm {atan}\left (\frac {\sin \left (\frac {c}{2}+\frac {d\,x}{2}\right )}{\cos \left (\frac {c}{2}+\frac {d\,x}{2}\right )}\right )}{d}+\frac {2\,a\,b\,\sin \left (c+d\,x\right )}{d\,\cos \left (c+d\,x\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________